#include "String.h"
#include <iostream>
using namespace std;

int String::getLength()
{
	char *p=string;
	while(*p!='\0')p++;
	return p-string;
}

char* String::getString() const
{
	return string;
}

void String::setString(char *s)
{
	string = s;
}

char* String::strncat(char* p,char *q)
{
	char *stringConnect = (char *)malloc(strlen(p)+strlen(q)+1);
	memset(stringConnect,0,strlen(p)+strlen(q)+1);
	char *s=stringConnect;
	for(;*p!='\0';p++) *s++=*p;
	for(;*q!='\0';q++) *s++=*q;
	return stringConnect;
}

int String::strnlen(char *p)
{
	int i=0;
	for(;*p!='\0';p++)i++;
	return i;
}

 ostream& operator <<(ostream&o,const String& m)
{
	o<<m.getString();
	return o;
}

 String& operator+(String& n,const String&m)
 {
	 n.setString(n.strncat(n.getString(),m.getString()));
	 return n;
 }